import { combineReducers } from 'redux'
import {
  SHOW_LOADING,
  SHOW_DIALOG,
  CHANGE_SHOP_NAME,
  CHANGE_SHOPIDS,
  SMS_SIGNATURE_STATUS
} from '../actions/index'


//todo 控制全局的loading状态
const loading = (state = false,action)=>{
  switch (action.type){
    case SHOW_LOADING:
      return action.loading;
    default:
      return state
  }
};

//todo 控制全局的Dialog状态
const showDialog = (state = { flag:false,text:'' },action)=>{
  switch (action.type){
    case SHOW_DIALOG:
      return Object.assign({},state,action.showDialog);
    default:
      return state
  }
};

//todo 改变商户名称
let initShopName = 'aaaa';
const shopName = (state = initShopName,action)=>{
  switch (action.type){
    case CHANGE_SHOP_NAME:
      return action.name;
    default:
      return state
  }
};
//改变shopIds的值
let initShopIds = 'bbbb';
const shopIds = (state = initShopIds,action)=>{
  switch (action.type){
    case CHANGE_SHOPIDS:
      return action.value;
    default:
      return state
  }
};

const smsSignatureInfoObj =(state = {signatureStatus:3,signature:''},action)=>{
  switch (action.type){
    case SMS_SIGNATURE_STATUS:
      return action.data;
    default:
      return state
  }
};

export default combineReducers({
  showDialog,
  loading,
  shopName,
  shopIds,
  smsSignatureInfoObj
})
